﻿// utf8模板
#ifndef _OI_MEASURE_TOOL_HPP_
#define _OI_MEASURE_TOOL_HPP_

#include "PLScannerCore/OiPLScannerCore.hpp"

namespace Oi
{
    namespace PLScannerCore
    {
        class MeasureTool :public QGraphicsItem
        {
        public:
            MeasureTool(const ProductParams& prdParam, QGraphicsItem* parent = nullptr);
            ~MeasureTool();

            QRectF boundingRect() const override;

            void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = Q_NULLPTR) override;
            void chaseMouse(bool);
            bool isChaseMouse();

        public:
            std::vector<QPointF> measure(const OiProfile& profile);
            void setResult(const std::vector<QPointF>& msrRes);
            void resetDisplayData();
            std::pair<std::vector<double>, std::vector<double>> calcResult();

        private:
            void drawCurValue(QPainter* painter, const QPointF& curPt, const QString& text, float maxVal, float minVal);
            void drawStdValue(QPainter* painter, const QPointF& prePt, const QString& preText, float maxVal, float minVal);

        protected:
            void hoverMoveEvent(QGraphicsSceneHoverEvent* event);

        private:
            OI_DISABLE_COPY(MeasureTool);
            OI_DECLARE_IMPL(MeasureTool);
        };
    }
}

#endif // !_OI_MEASURE_TOOL_HPP_

